<link href="../../static/css/jeDate-test.css" rel="stylesheet" th:href="@{/css/jeDate-test.css}"
      xmlns:th="http://www.w3.org/1999/xhtml"/>
<link href="../../static/css/jedate.css" rel="stylesheet" th:href="@{/css/jedate.css}"/>
<script src="../../static/js/jquery.jedate.js" th:src="@{/js/jquery.jedate.js}"></script>
<script src="../../static/js/jedate-test.js" th:src="@{/js/jedate-test.js}"></script>
<script type="text/javascript" src="../../static/js/prompt.js" th:src="@{/js/prompt.js}"></script>
<div class="row">
    <div class="form-group">
        <!--<div class="panel-heading">-->
        <!--<div class="panel-btns">-->
        <!--<a href="" class="panel-close">×</a>-->
        <!--<a href="" class="minimize">−</a>-->
        <!--</div>&lt;!&ndash; panel-btns &ndash;&gt;-->
        <!--<h5 class="panel-title">Unresolved By Priority</h5>-->
        <!--</div>-->
        <div class="panel-body panel-table">
            <div class="table-responsive">
                <table class="table">
                    <thead>
                    <tr class="table-head-alt">
                        <th><button type="button" onclick="allcheck()" class="btn-sm btn-primary">全选</button></th>
                        <th>序号</th>
                        <th>展厅--展位</th>
                        <th>发表日期</th>
                        <th>昵称</th>
                        <th>评分</th>
                        <th>状态</th>
                        <th>操作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class="btn-sm btn-primary" type="button" onclick="delAll()">批量删除</button></th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="data,dataStat:${datas.content}">
                        <th> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="check" th:value="${data.id}"></th>
                        <td th:text="${dataStat.count}">1</td>
                        <td th:text="${data.exhibitionName}">第二展厅-展位</td>
                        <td th:text="${#dates.format(data.cdate, 'yyyy-MM-dd')}">2018-01-01</td>
                        <td th:text="${data.name}">zzp</td>
                        <td th:text="${data.star}">5</td>
                        <td>
                            <span th:if="${data.sts == 0}" ><b>通过</b></span>
                            <span th:if="${data.sts == 1}">未通过</span>
                        </td>
                        <td>
                            <button class="btn-sm btn-primary" th:id="${data.id}" onclick="del(this)">删除
                            </button>&nbsp;
                            <button class="btn-sm btn-primary" th:id="${data.id}" th:value="${data.content}"
                                    data-toggle="modal" data-target="#myModal" onclick="appraises(this)">评价详情
                            </button>&nbsp;
                            <button class="btn-sm btn-primary" th:id="${data.id}" onclick="allow(this)">通过</button>&nbsp;
                            <button class="btn-sm btn-primary" th:id="${data.id}" onclick="notAllow(this)">不通过</button>&nbsp;
                        </td>
                    </tr>
                    </tbody>
                </table>
                <div id="pagination" class="col-md-12 pagination" th:replace="pagination :: pagination"></div>
            </div><!-- table-responsive -->
        </div>
    </div>
</div>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">评价详情</h4>
                <div id="exhibitionName"></div>
            </div>
            <div class="modal-body">
                <div class="" id="appraiseDetail"></div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" onclick="closs()">关闭</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    var check =0;
    function allcheck() {
        if(check==0){
            $('input:checkbox').prop("checked", true);
            check=1;
        }else {
            $('input:checkbox').prop("checked", false);
            check=0;
        }
        
    }
    function delAll() {
        var input = $("input:checkbox:checked");
        var ids ="";
        $.each(input,function (index,item) {
            ids +=item.defaultValue+",";
        })
        $.post("appraise/delAll", {"id": ids}, function (result) {
            if (result == 0) {
                alert("删除成功！")
                $.goTo(/*[[@{appraiseTurn/getAllAppraises}]]*/"./appraise/appraise.html");
            } else {
                alert("删除失败！")
            }
        })
    }
    function allow(data) {
        // console.log(data)
        var id = $(data).attr("id");
        // alert(id);
        $.get("appraise/changeSts", {"id": id, "sts": 0}, function (result) {
            if (result == 0) {
                alert("审核通过！")
                $.goTo(/*[[@{appraiseTurn/getAllAppraises}]]*/"./appraise/appraise.html");
            } else {
                alert("审核失败！")
            }
        })
    }
    function del(data) {
        var id = $(data).attr("id");
        $.post("appraise/del", {"id": id}, function (result) {
            if (result == 0) {
                alert("删除成功！")
                $.goTo(/*[[@{appraiseTurn/getAllAppraises}]]*/"./appraise/appraise.html");
            } else {
                alert("删除失败！")
            }
        })
    }

    function notAllow(data) {
        var id = $(data).attr("id");
        $.get("appraise/changeSts", {"id": id, "sts": 1}, function (result) {
            if (result == 1) {
                alert("未通过审核！")
                $.goTo(/*[[@{appraiseTurn/getAllAppraises}]]*/"./appraise/appraise.html");
            } else {
                alert("审核失败！")
            }
        })
    }
    //data.css("background","#428bca");
    var  temp;
    function closs() {
        $(temp).css("background","#428bca");
    }
    function appraises(data) {
        $(data).css("background","#ff0000");
        temp =data;
        var id = $(data).attr("id");
        $.post("appraise/findOne", {"lid": id}, function (request) {
            console.log(request);
            $("#exhibitionName").empty();
            $("#exhibitionName").append(request.exhibitionName);
        });
        $("#appraiseDetail").empty();
        $("#appraiseDetail").append($(data).attr("value"));
    }

    function up(number) {//分页跳转，上一页
        /*[+
         var number = parseInt(number);
         $.goTo("appraiseTurn/getAllAppraises?page="+number);
         +]*/
    }

    function next(number) {//分页跳转，下一页
        /*[+
         var number = parseInt(number) + 2;
         $.goTo("appraiseTurn/getAllAppraises?page="+number);
         +]*/
    }

    function pageTo(page) {
        /*[+
         var number = page;
         $.goTo("appraiseTurn/getAllAppraises?page=" + number);
         +]*/
    }

    /*]]>*/
</script>